function $(id){
		return document.getElementById(id);
	}
	//顶部导航  显示
	function showNav(a){

		var nav;
		nav = $('nav'+a);
		nav.style.display="block";
		$('xuanzhuan'+a).className='xuanzhuanA';
		if (a==1) {
			$('gongying').style.backgroundColor="#fff";
		}else if(a==2){
			$('fuwu').style.backgroundColor="#fff";
		}else if(a==3){
			$('kefu').style.backgroundColor="#fff";
		}
	}
	//顶部导航  消失
	function closeNav(a){
		var close;
		close = $('nav'+a);
		close.style.display="none";
		$('xuanzhuan'+a).className='xuanzhuanB';
		if (a==1) {
			$('gongying').style.backgroundColor="#eaeaea";
		}else if(a==2){
			$('fuwu').style.backgroundColor="#eaeaea";
		}else if(a==3){
			$('kefu').style.backgroundColor="#eaeaea";
		}
	}

	function shangpins(){
		$('right_firstpic').style.display="block";
	}
	function shangpins2(){
		$('right_firstpic').style.display="none";
	}
	function shangpiny(){
		$('right_cecondpic').style.display="block";
	}
	function shangpiny2(){
		$('right_cecondpic').style.display="none";
	}
	function huanpic(a){
		$('firstpic_rightpic').src="supplier/right"+a+".jpg";
	}
	function huanpic2(a){
		$('cecondpic_rightpic').src="supplier/xia"+a+".jpg";
	}
	window.setTimeout(miao,10);
	window.setTimeout(fen,10);
	window.setTimeout(shi,10);
	window.setTimeout(tian,10);
		var sec=5;   //初始值状态
		var min=2;
		var hour=1;
		var day=2;
	function miao(){
		if (sec==-1) {
			$('sec').innerHTML="59";
			sec=59;
			setTimeout(miao,0);
			fen();
		}else {
			$('sec').innerHTML=sec;
			sec--;
			setTimeout(miao,1000);
		}
	}
	function fen(){
		if (min==-1) {
			$('min').innerHTML="59";
			min=59;
			shi();
		}else{
			$('min').innerHTML=min;
			min--;
		}
	}
	function shi(){
		if (hour==-1) {
			$('hour').innerHTML="23";
			hour=23;
			day();
		}else{
			$('hour').innerHTML=hour;
			hour--;
		}
	}
	function tian(){
		if (day==-1) {
			$('day').innerHTML="4";
			day=4;
		}else{
			$('day').innerHTML=day;
			day--;
		}
	}
	function xuanzhong(a){
		$('txt5_1_pic3').style.display='block';
		if (a==1) {
			$('txt5_1_pic2').style.border="1px solid #ccc";
			$('txt5_1_pic2').style.position="";
			$('txt5_1_pic3').style.margin="39px 0 0 99px";
			$('txt5_1_pic'+a).style.border="1px solid #e60000";
			// $('txt5_1_pic'+a).style.position="relative";
		}else if (a==2){
			$('txt5_1_pic1').style.border="1px solid #ccc";
			$('txt5_1_pic1').style.position="";
			$('txt5_1_pic3').style.margin="39px 0 0 161px";
			$('txt5_1_pic'+a).style.border="1px solid #e60000";
			// $('txt5_1_pic'+a).style.position="relative";
		}
	}
	function xuanzhong1(a){
		$('txt5_1_pic4').style.display="block";
		var div = $('txt5_2').getElementsByTagName('div');
		for(var i=0; i<div.length;i++){
			if (i==a){
				$('txt5_1_pic4').style.border="";
				$('txt5_1_pic4').style.margin="9px 0 0 "+((i-1)*56.7+88.5)+"px";
				div[i-1].style.border="1px solid #e60000";
				div[i].style.border="1px solid #ccc";
					if (i==5) {
						div[i].style.border="none";
					}
			}else{
				div[i].style.border="1px solid #ccc";
				$('txt5_1_pic4').style.border="";
			}
		}
	}
	var add=1;
	function countAdd(){
		if (add>=4) {
			$('count_tip').innerHTML="亲，每个ID最多只能购买5件";
			$('count').innerHTML=5;
			$('count_add').style.borderBottom="12px solid #cfcfcf";
		}else{
			add++;
			$('count').innerHTML=add;
			$('count_tip').innerHTML="";
			$('count_add').style.borderBottom="12px solid #aaa";
			$('count_jian').style.borderTop="12px solid #aaa";
		}
		
	}
	function countJian(){
		if (add<=1) {
			$('count_tip').innerHTML="";
			$('count').innerHTML=1;
			$('count_jian').style.borderTop="12px solid #cfcfcf";
		}else{
			$('count').innerHTML=add;
			$('count_tip').innerHTML="";
			$('count_add').style.borderBottom="12px solid #aaa";
			$('count_jian').style.borderTop="12px solid #aaa";
			add--;
		}
	}

// s放大镜事件
	function goodsPic(a){
		// var pic = $('S_pic').getElementsByTagName('div');
		$('goods_pic_M').src='supplier/goods_pic'+a+'.jpg';
		$('goods_pic_Big').src='supplier/goods_pic'+a+'.jpg';
	}

	function showBigpic(){
		$('Big_pic').style.display="block";
		$('mdiv').style.display="block";
	}
	function closeBigpic(){
		$('Big_pic').style.display="none";
		$('mdiv').style.display="none";
	}

	// 移动的x目标值，y目标值，x方向缓动的值，y方向缓动的值
	var targetX=0,targetY=0,leaderX=0,leaderY=0;
	function mdivMove(event){

		var event = event || window.event;
		var b_top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
		targetX = event.clientX-$('con_cen_pic').offsetLeft-11-$('mdiv').offsetWidth/2;
		targetY = event.clientY-$('con_cen_pic').offsetTop+b_top-$('mdiv').offsetHeight/2;
		if (targetX<0){
			targetX=0;
		}else if(targetX>$('goods_pic').offsetWidth-$('mdiv').offsetWidth){
			targetX=$('goods_pic').offsetWidth-$('mdiv').offsetWidth;
		}
			// console.log(event.clientX);
			// console.log($('goods_pic').offsetLeft);
		if (targetY<0){
			targetY=0;
		}else if(targetY>$('goods_pic').offsetHeight-$('mdiv').offsetHeight){
			targetY=$('goods_pic').offsetHeight-$('mdiv').offsetHeight;
		}
			// console.log($('goods_pic').offsetTop);
	}

	setInterval(function(){
		leaderX = leaderX + (targetX-leaderX)/5;
		leaderY = leaderY + (targetY-leaderY)/5;

		$('mdiv').style.left = leaderX+"px";
		$('mdiv').style.top = leaderY+"px";

		var xb = $('goods_pic_Big').offsetWidth/$('goods_pic_M').offsetWidth;
		var yb = $('goods_pic_Big').offsetHeight/$('goods_pic_M').offsetHeight;
		// console.log(yb);
		$('goods_pic_Big').style.left = -leaderX*xb+"px";
		$('goods_pic_Big').style.top = -leaderY*yb+"px";
		// console.log($('goods_pic_Big').style.left );
	},10);

// content2中的JS
function goodsContent2(a){
	var div = $('con2_l_nav').getElementsByTagName('div');
	for(var i=0 ; i<div.length;i++){
		if (i==a) {
			div[i].className="content2_onclick";
			$('goods_C_div'+a).style.display="block";
		}else{
			div[i].className="";
			$('goods_C_div'+i).style.display="none";
		}
	}
}

var beijingtimes;
function postMsg(){
	if ($('sendC_area').value=="") {
		$('sendC_tip').style.visibility="visible";
	}else{
		$('sendC_tip').style.visibility="hidden";

		// 获得ul下的li子节点
	var childrens = $('comment_list').children;
		// 克隆第一个li子节点
	var li = $("comment1").cloneNode(true);
		// 克隆的li插入到第一个li前
	$('comment_list').insertBefore(li,childrens[0]);
	
		var divs=childrens[0].getElementsByTagName('div');
		// 传入发表的内容
		divs[6].innerHTML=$('sendC_area').value;
		// 清空编辑评论区的内容
		$('sendC_area').value = "";
		 // 传入发表时的时间
		 beijingtime();
		 divs[4].innerHTML=beijingtimes;

		 var arr_a = $('comment_list').getElementsByTagName('a');
		 for(var i=0; i<arr_a.length;i++){
		 	arr_a[i].onclick = function(){
		 		$('comment_list').removeChild(this.parentNode);
		 	}
		 }
	}
}

	function beijingtime(){
		var day=new Date();
		 var year=day.getFullYear();
		 var month=day.getMonth()+1;
		 var date=day.getDate();
		 var hours=day.getHours();
		 var minutes=day.getMinutes();
		 var seconds=day.getSeconds();
		 var week=day.getDay();
		 if(month<10){
			month="0"+month;
		 }
		 if(date<10){
			date="0"+date;
		 }
		 if(hours<10){
			hours="0"+hours;
		 }
		 if(minutes<10){
			minutes="0"+minutes;
		 }
		 if(seconds<10){
			seconds="0"+seconds;
		 }
		 var str=year+"年"+month+"月"+date+"日"+" "+hours+":"+minutes+":"+seconds+" "+"星期"+week;

		 beijingtimes=str;
	}
	
	function hyhout(){
		$('con2_change').style.background="RGBA(255,255,255,0.1)";
		$('con2_change').style.color="black";
	}
	function hyhover(){
		$('con2_change').style.background="#e60000";
		$('con2_change').style.color="white";
	}
	
	// var rightTop=600;
	// var aaa=0;
	var speed=20;
	var ui=0;
	function huanyihuan(){
		
		var divs=$("content2_right2").getElementsByTagName('div');
			if (ui==0) {
				var myval0=setInterval(function(){
					// 1
					var mytop=parseInt(divs[0].style.top);
					if (mytop>-610){
						divs[0].style.top=(mytop-speed)+"px";
					}else{
						divs[0].style.top="1200px";
						clearInterval(myval0);
					}
					// 2
					var mytop1=parseInt(divs[1].style.top);
					if (mytop1>0) {
						divs[1].style.top=(mytop1-speed)+"px";
					}else{
						divs[1].style.top="0px";
					}
					// 3
					var mytop2=parseInt(divs[2].style.top);
					if (mytop2>600){
						divs[2].style.top=(mytop2-speed)+"px";
					}else{
						divs[2].style.top="600px";
					}
				},100);
			}else if(ui==1) {
				var myval1=setInterval(function(){
					// 1
					var mytop=parseInt(divs[0].style.top);
					if (mytop>600){
						divs[0].style.top=(mytop-speed)+"px";
					}else{
						divs[0].style.top="600px";
					}
					// 2
					var mytop1=parseInt(divs[1].style.top);
					if (mytop1>-600) {
						divs[1].style.top=(mytop1-speed)+"px";
					}else{
						divs[1].style.top="1200px";
						clearInterval(myval1);
					}
					// 3
					var mytop2=parseInt(divs[2].style.top);
					if (mytop2>0){
						divs[2].style.top=(mytop2-speed)+"px";
					}else{
						divs[2].style.top="0px";
					}
				},100);
			}else{
				var myval2=setInterval(function(){
					// 1
					var mytop=parseInt(divs[0].style.top);
					if (mytop>0){
						divs[0].style.top=(mytop-speed)+"px";
					}else{
						divs[0].style.top="0px";
					}
					// 2
					var mytop1=parseInt(divs[1].style.top);
					if (mytop1>600) {
						divs[1].style.top=(mytop1-speed)+"px";
					}else{
						divs[1].style.top="600px";
					}
					// 3
					var mytop2=parseInt(divs[2].style.top);
					if (mytop2>-600){
						divs[2].style.top=(mytop2-speed)+"px";
					}else{
						divs[2].style.top="1200px";
						clearInterval(myval2);
					}
				},100);
			}
		ui++;
		if (ui>=3) {
			ui=0;
		}
	}
		